package com.spring.util;

import com.spring.aware.ApplicationContextAware;
import com.spring.context.impl.AbstractApplicationContext;

/**
 * @author ljj
 */
public final class SpringUtil implements ApplicationContextAware {
	
	private static AbstractApplicationContext ac;
	
	@Override
	public void setApplicationContext(AbstractApplicationContext applicationContext) {
		ac = applicationContext;
	}
	
	
	public static AbstractApplicationContext getContext() {
		return ac;
	}
	
	/**
	 * 静态方法对外提供
	 */
	public static Object getBean(String name) {
		return ac.getBean(name);
	}
	
	/**
	 * 静态方法对外提供
	 */
	public static <T> T getBean(String name, Class<T> clazz) {
		return ac.getBean(name, clazz);
	}
}
